/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package test.entities;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.*;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Issam
 */
@Entity
@Table(name = "PORTEFEUILLE", catalog = "", schema = "NETTRADING")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Portefeuille.findAll", query = "SELECT p FROM Portefeuille p"),
    @NamedQuery(name = "Portefeuille.findByNumPort", query = "SELECT p FROM Portefeuille p WHERE p.numPort = :numPort"),
    @NamedQuery(name = "Portefeuille.findByDateOuverture", query = "SELECT p FROM Portefeuille p WHERE p.dateOuverture = :dateOuverture")})
public class Portefeuille implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "NUM_PORT", nullable = false)
    @GeneratedValue(strategy= GenerationType.AUTO)
    private Integer numPort;
    @Basic(optional = false)
    @Column(name = "DATE_OUVERTURE", nullable = false)
    @Temporal(TemporalType.TIMESTAMP)
    private Date dateOuverture;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "portefeuille")
    private Collection<PortefeuilleAction> portefeuilleActionCollection;
    @JoinColumn(name = "EMAIL", referencedColumnName = "EMAIL", nullable = false)
    @ManyToOne(optional = false)
    private Client email;

    public Portefeuille() {
    }

    public Portefeuille(Integer numPort) {
        this.numPort = numPort;
    }

    public Portefeuille(Integer numPort, Date dateOuverture) {
        this.numPort = numPort;
        this.dateOuverture = dateOuverture;
    }

    public Integer getNumPort() {
        return numPort;
    }

    public void setNumPort(Integer numPort) {
        this.numPort = numPort;
    }

    public Date getDateOuverture() {
        return dateOuverture;
    }

    public void setDateOuverture(Date dateOuverture) {
        this.dateOuverture = dateOuverture;
    }

    @XmlTransient
    public Collection<PortefeuilleAction> getPortefeuilleActionCollection() {
        return portefeuilleActionCollection;
    }

    public void setPortefeuilleActionCollection(Collection<PortefeuilleAction> portefeuilleActionCollection) {
        this.portefeuilleActionCollection = portefeuilleActionCollection;
    }

    public Client getEmail() {
        return email;
    }

    public void setEmail(Client email) {
        this.email = email;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (numPort != null ? numPort.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Portefeuille)) {
            return false;
        }
        Portefeuille other = (Portefeuille) object;
        if ((this.numPort == null && other.numPort != null) || (this.numPort != null && !this.numPort.equals(other.numPort))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "test.entities.Portefeuille[ numPort=" + numPort + " ]";
    }
    
}
